<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	<script type="text/javascript">
	PrimeFaces.locales['pt_BR'] = {
            closeText: 'Fechar',
            prevText: 'Anterior',
            nextText: 'Próximo',
            currentText: 'Começo',
            monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
            monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun', 'Jul','Ago','Set','Out','Nov','Dez'],
            dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
            dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
            dayNamesMin: ['D','S','T','Q','Q','S','S'],
            weekHeader: 'Semana',
            firstDay: 1,
            isRTL: false,
            showMonthAfterYear: false,
            yearSuffix: '',
            timeOnlyTitle: 'Só Horas',
            timeText: 'Tempo',
            hourText: 'Hora',
            minuteText: 'Minuto',
            secondText: 'Segundo',
            currentText: 'Data Atual',
            ampm: false,
            month: 'Mês',
            week: 'Semana',
            day: 'Dia',
            allDayText : 'Todo Dia'
        };
    	function limparCamposAliquota(){
        	document.getElementById("descricaoAliquota").value = "";
        	document.getElementById("aliquotaAliquota").value = "";
        	document.getElementById("valorInicialAliquota").value = "";
        	document.getElementById("valorFinalAliquota").value = "";
    	}
	</script>
	<p:outputPanel id="painelInclusao" rendered="#{tabelaINSSBean.modoInclusao or tabelaINSSBean.modoEdicao}">
		<p:panel header="Cadastro de Tabela de INSS">
			<p:focus for="descricaoInclusao" id="focusPaginaInclusao"/>
			<h:panelGrid columns="2" id="painel2ColunasInclusao">
				<h:outputLabel value="#{msg['label.tabelaINSS.descricao']}" for="descricaoInclusao" id="labelDescricaoInclusao"/>
				<p:inputText value="#{tabelaINSSBean.entity.descricao}" id="descricaoInclusao" required="true" requiredMessage="#{msg['tabelaINSS.descricao.obrigatorio']}" title="#{msg['title.tabelaINSS.descricao']}" size="100" maxlength="255"/>
				<h:outputLabel value="#{msg['label.tabelaINSS.dataInicioVigencia']}" for="dataInicioVigenciaInclusao" id="labelDataInicioVigenciaInclusao"/>
				<p:calendar value="#{tabelaINSSBean.entity.dataInicioVigencia}" id="dataInicioVigenciaInclusao" timeZone="America/Sao_Paulo" pattern="dd/MM/yyyy" lang="pt" locale="pt_BR" navigator="true" required="true" requiredMessage="#{msg['tabelaINSS.dataInicioVigencia.obrigatorio']}" showButtonPanel="true"/>
				<h:outputLabel value="#{msg['label.tabelaINSS.dataTerminoVigencia']}" for="dataTerminoVigenciaInclusao" id="labelDataTerminoVigenciaInclusao"/>
				<p:calendar value="#{tabelaINSSBean.entity.dataTerminoVigencia}" id="dataTerminoVigenciaInclusao" timeZone="America/Sao_Paulo" pattern="dd/MM/yyyy" lang="pt" locale="pt_BR" navigator="true" showButtonPanel="true"/>
			</h:panelGrid>
		</p:panel>
		<p:panel header="Incluir Alíquotas de INSS" id="painelInclusaoAliquotaINSS">
			<h:panelGrid columns="10">
				<h:outputLabel value="#{msg['label.aliquotaINSS.descricao']}" for="descricaoAliquota" id="labelDescricaoAliquota"/>
				<p:inputText value="#{tabelaINSSBean.aliquotaINSS.descricao}" id="descricaoAliquota"/>
				<h:outputLabel value="#{msg['label.aliquotaINSS.aliquota']}" for="aliquotaAliquota" id="labelAliquotaAliquota"/>
				<p:inputText value="#{tabelaINSSBean.aliquotaINSS.aliquota}" id="aliquotaAliquota" size="6" maxlength="6">
					<f:convertNumber locale="pt_BR" pattern="#00,00" />
				</p:inputText>
				<h:outputLabel value="#{msg['label.aliquotaINSS.valorInicial']}" for="valorInicialAliquota" id="labelValorInicialAliquota" />
				<p:inputText value="#{tabelaINSSBean.aliquotaINSS.valorInicial}" size="10" maxlength="10" id="valorInicialAliquota">
					<f:convertNumber locale="pt_BR" pattern="#00,00" />
				</p:inputText>
				<h:outputLabel value="#{msg['label.aliquotaINSS.valorFinal']}" for="valorFinalAliquota" id="labelValorFinalAliquota" />
				<p:inputText value="#{tabelaINSSBean.aliquotaINSS.valorFinal}" size="10" maxlength="10" id="valorFinalAliquota">
					<f:convertNumber locale="pt_BR" pattern="#00,00" />
				</p:inputText>
				<p:commandButton value="Limpar" type="button" onclick="javascript:limparCamposAliquota()" />
				<p:commandButton value="Adicionar" update="form:mensagens aliquotasINSS @parent" action="#{tabelaINSSBean.reinitAliquotasINSS}" process="painelInclusaoAliquotaINSS" id="botaoAdicionarAliquotaINSS">
					<p:collector value="#{tabelaINSSBean.aliquotaINSS}" addTo="#{tabelaINSSBean.entity.listaAliquotasINSS}" />
				</p:commandButton>
			</h:panelGrid>
		</p:panel>
		<p:outputPanel id="aliquotasINSS">
			<p:dataTable value="#{tabelaINSSBean.entity.listaAliquotasINSS}" var="aliquotaINSS" emptyMessage="#{msg['info.aliquotaINSS.nao.informados']}" rows="20" paginator="true" id="dataTableAliquotas">
				<p:column>
					<f:facet name="header"><h:outputText value="#{msg['label.aliquotaINSS.descricao']}"/></f:facet>
					<h:outputText value="#{aliquotaINSS.descricao}" />
				</p:column>
				<p:column>
					<f:facet name="header"><h:outputText value="#{msg['label.aliquotaINSS.aliquota']}"/></f:facet>
					<h:outputText value="#{aliquotaINSS.aliquota}">
						<f:convertNumber minFractionDigits="2" locale="pt_BR"/>
					</h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header"><h:outputText value="#{msg['label.aliquotaINSS.valorInicial']}"/></f:facet>
					<h:outputText value="#{aliquotaINSS.valorInicial}">
						<f:convertNumber type="currency" minFractionDigits="2" locale="pt_BR"/>
					</h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header"><h:outputText value="#{msg['label.aliquotaINSS.valorFinal']}"/></f:facet>
					<h:outputText value="#{aliquotaINSS.valorFinal}">
						<f:convertNumber type="currency" minFractionDigits="2" locale="pt_BR"/>
					</h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header"><h:outputText value="Operação"/></f:facet>
					<p:commandLink value="Remover" update="dataTableAliquotas" immediate="true">
						<p:collector value="#{aliquotaINSS}" removeFrom="#{tabelaINSSBean.entity.listaAliquotasINSS}" />
					</p:commandLink>
				</p:column>
			</p:dataTable>
		</p:outputPanel>
	</p:outputPanel>
</ui:composition>